package com.example.demo.unirest;

import com.alibaba.fastjson.JSONArray;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <内容说明>
 *
 * @author yu.guangqi
 * created on 2019/3/18 9:27
 */
public class UnirestTest {

    public static void main(String[] args) throws Exception {
        List list=new ArrayList();
        list.add("010c33a530213023300431c2313538003632363132");
//        list.add("234");
        JSONArray jsonArray=new JSONArray();
        jsonArray.addAll(list);
        System.out.println(jsonArray.toJSONString());

        String url = "http://120.197.233.126:8081/wsArouseSms/rest/v2.0/msg/sendEx";
        Map<String, Object> map = new HashMap();
        map.put("api_key","300011862612");
        map.put("timestamp","1561084368685");
        map.put("expires","600");
        map.put("device_tokens",jsonArray.toJSONString());
        map.put("sign","4/81MjBiTdOBEwCFpqMtRdGhhl8Fw++aCRioxe7lQi4=");
        map.put("data","{\"templateId\":-1,\"parameters\":\"\",\"msg\":\"aHR0cDovL2ppYW5nYmluZy5pcWl5aS5jb20vYS8jL2FiY2Rl\"}");
        map.put("type","1");
        HttpResponse<JsonNode> httpResponse = Unirest.post(url)
                .header("Content-Type", "application/x-www-form-urlencoded;charset=utf-8")
                .queryString(map).asJson();
        System.out.println(httpResponse.getStatus());
        System.out.println(httpResponse.getBody());
    }
}
